package main.java.Thread;

public class ticket {
    public static void main(String[] args) throws InterruptedException {
        seller s1 = new seller();
        seller s2 = new seller();
        seller s3 = new seller();
        s1.start();
        s2.start();
        s3.start();
        Thread.sleep(2000);
        s2.interrupt();
    }
}
class seller extends Thread {
    static int ticket_num = 100;
    static boolean sellable = true;

    @Override
    public void run() {
        while (ticket_num > 0 && sellable){
            try {
                Thread.sleep(1000);
                System.out.println(Thread.currentThread().getName() + "卖票一张，还剩" + --ticket_num);
            } catch (InterruptedException e) {
                System.out.println(Thread.currentThread().getName() + "被中断了！！！！");
            }
        }
    }
    public void stopsell(){
        sellable = false;
    }
}

